// pages/syudy/examResultPreview/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    examResult: [],
    defaultQu: {},
    active: 0,
    index: 0,
    chooseOption: []

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.setNavigationBarTitle({
      title: '结果回顾',
    })
    this.geInfo();
    let paperContent = JSON.parse(wx.getStorageSync('thisExamResult').paperContent);
    console.log(paperContent)
  },
  //获取答题记录
  geInfo() {
    wx.http.get(getApp().globalData.getExamResultInfo,{
      examResultId:wx.getStorageSync('examResultId')
    }).then(res => {
      console.log(res)
    if(res.code ==200){
     const content =  JSON.parse(res.data.paperContent)
     console.log(content)
      this.setData({
        examResult:content,
        defaultQu:content[0]
      })
    }
    })

  },
  //标签切换
  onChange(event) {
    this.setData({ active: event.detail });
  },
  //上一题
  upQuesiton() {
    this.setData({
      index: this.data.index - 1,
      defaultQu: this.data.examResult[this.data.index]
    })

  },
  //下一题
  downQuestion() {
    this.setData({
      index: this.data.index + 1,
      defaultQu: this.data.examResult[this.data.index],
      chooseOption: this.data.examResult[this.data.index].chooseOption.split(",")
    })
    console.log(this.data.chooseOption)
  },

})